<?php
    $this->headLink()
        ->prependStylesheet($this->baseUrl().'/application/css.php?request=application/modules/Flashgame/externals/styles/main-widgets.css')
        ->prependStylesheet($this->baseUrl().'/application/css.php?request=application/modules/Flashgame/externals/styles/tooltip.css');                                                                                     
    $counter = 0;
?>
<ul>
<?php
foreach( $this->games as $game): 
	$title = $game->getTitle();
	if (strlen($title) > 10)
		$title = substr($title, 0, 10) . '..';
	$owner_name = $game->getOwner()->getTitle();
	if (strlen($owner_name) > 10)
		$owner_name = substr($owner_name, 0, 10) . '..';
?>
<?php
if($counter ==0){
?>
    <div style="margin-bottom: 10px; padding-top: 10px; border-top: #cccccc solid 0px;">
        <div class="widget_innerholder_flashgame">
            <?php
                if ($game->photo_id)
                    echo $this->htmlLink($game->getHref(), $this->itemPhoto($game, '', $game->getTitle(),array('width' => '60', 'height' => '50')));
                else
                    echo $this->htmlLink($game->getHref(),'<img alt="" src="application/modules/Flashgame/externals/images/nophoto.png" width="60" height="50">');
            ?>
        </div>
        <div class='games_widget_item_info' style="float: left; width: auto;">
            <p class='games_widget_item_info_title'>
                <a class="game" href="<?php echo $game->getHref(); ?>"><?php echo $title; ?>
                <span class="tooltip"><span class="top"></span><span class="middle"><strong><?php echo $game->getTitle(); ?>&nbsp;</strong><br /></span><span class="bottom"></span></span></a>
            </p>
            <div class='games_widget_item_info_info'>
                <?php echo $this->translate('By');?> <?php echo $this->htmlLink($game->getOwner()->getHref(), $owner_name) ?>
                <div>
                    <?php for($i = 1; $i <= 5; $i++): ?>
                        <img border="0" src="application/modules/Flashgame/externals/images/<?php if ($i <= $game->rates): ?>star_full.png<?php elseif( $i > $game->rates &&  ($i-1) <  $game->rates): ?>star_part.png<?php else: ?>star_none.png<?php endif; ?>" width="10px" />
                    <?php endfor; ?>
                </div>
                <?php echo $this->translate('Plays:') . ' '. number_format($game->view_count, 0, '', ','); ?>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
    
<?php
    $counter += 1;
}
else
{
?>

    <div style="margin-bottom: 10px; padding-top: 10px; border-top: #cccccc solid 1px;">
        <div class="widget_innerholder_flashgame">
            <?php
                if ($game->photo_id)
                    echo $this->htmlLink($game->getHref(), $this->itemPhoto($game, '', $game->getTitle(),array('width' => '60', 'height' => '50')));
                else
                    echo $this->htmlLink($game->getHref(),'<img alt="" src="application/modules/Flashgame/externals/images/nophoto.png" width="60" height="50">');
            ?>
        </div>
        <div class='games_widget_item_info' style="float: left; width: auto;">
            <p class='games_widget_item_info_title'>
                 <a class="game" href="<?php echo $game->getHref(); ?>"><?php echo $title; ?>
                <span class="tooltip"><span class="top"></span><span class="middle"><strong><?php echo $game->getTitle(); ?>&nbsp;</strong><br /></span><span class="bottom"></span></span></a>
            </p>
            <div class='games_widget_item_info_info'>
                <?php echo $this->translate('by');?> <?php echo $this->htmlLink($game->getOwner()->getHref(), $owner_name) ?>
                <div>
                    <?php for($i = 1; $i <= 5; $i++): ?>
                        <img border="0" src="application/modules/Flashgame/externals/images/<?php if ($i <= $game->rates): ?>star_full.png<?php elseif( $i > $game->rates &&  ($i-1) <  $game->rates): ?>star_part.png<?php else: ?>star_none.png<?php endif; ?>" width="10px" />
                    <?php endfor; ?>
                </div>
                <?php echo $this->translate('Plays:') . ' '. number_format($game->view_count, 0, '', ','); ?>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
<?php
    $counter += 1;
}
?>
<?php endforeach; ?>
    <div style="clear: both;"></div>

    <div class="link_view" style="display: block; text-align: right;">
        <a href="<?php echo $this->url(array('module'=>'games'), 'default', true) ;?>">
            <?php echo $this->translate('View all');?>
        </a>
    </div>

</ul>